package com.xwj.strategy.demo1;

/**
 * @author xwj
 * @date 2020/6/28
 */
public class RewardContext {
    private RewardStrategy strategy;

    public RewardContext(RewardStrategy strategy) {
        this.strategy = strategy;
    }

    public void doStrategy(long userId) {
        int rewardMoney = strategy.reward(userId);
    }

    public static void main(String[] args) {
        // 创建工厂
        FactorRewardStrategyFactory strategyFactory = new FactorRewardStrategyFactory();

        NewUserRewardStrategyA newUserBasicReward = (NewUserRewardStrategyA) strategyFactory.createStrategy(NewUserRewardStrategyA.class);
        RewardContext rewardContext = new RewardContext(newUserBasicReward);
        // 执行返奖策略
        rewardContext.doStrategy(1);
    }
}